<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function check(){
				let d1=document.getElementById("d1").value
				if (d1=="") {
					document.getElementById("r1").innerHTML="姓名不能为空"
					return false
				}
				let d2=document.getElementById("d2").value
				if (d2.length<6) {
					document.getElementById("r2").innerHTML="密码长度不小于6"
					return false
				}
				let d3=document.getElementById("d3").value
				if (isNaN(d3)||d3<0||d3>150) {
					document.getElementById("r3").innerHTML="年龄必须在0-150"
					return false
				}
				let d4=document.getElementById("d4").value
				let reg=/^1[0-9]{10}$/
				if (!reg.test(d4)) {
					document.getElementById("r4").innerHTML="1开头的11位数字"
					return false
				}
				return true
			}
		</script>
	</head>
	<body>
		<form action="ok.html" method="get" onsubmit="return check()">  <!-- return 表单onsubmit 允许接收返回值 -->
			姓名：<input type="text" id="d1"><span id="r1"></span> <br>
			密码：<input type="text" id="d2"><span id="r2"></span> <br>
			年龄：<input type="text" id="d3"><span id="r3"></span> <br>
			手机：<input type="text" id="d4"><span id="r4"></span> <br>
			<input type="submit" value="提交"/>
		</form>
		<script type="text/javascript">
			
		</script>
	</body>
</html>
